package com.qige.homework.test;
/*
一、 需求说明：创建三个图书类对象，找出价格最高的图书并打印该图书的所有信息。
二、 设计“图书类”Book，要求有以下属性：
     图书编号：
     书名：
     价格：
 */
class Book{
    private int id;
    private String name;
    private double price;

    public Book() {
    }

    public Book(int id, String name, double price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
    public void show(){
        System.out.println("图书编号："+id+" 书名："+name+" 价格："+price);
    }
}
public class homework5 {
    public static void main(String[] args) {
        Book[] books = new Book[3];
        books[0] = new Book(1,"java",100);
        books[1] = new Book(2,"c++",200);
        books[2] = new Book(3,"python",300);
        double max = books[0].getPrice();
        for (int i = 0; i < 3; i++) {
            if (books[i].getPrice() > max){
                max = books[i].getPrice();
                break;
            }
        }
        for (int i = 0; i < 3; i++) {
            if (books[i].getPrice() == max){
                books[i].show();
                break;
            }
        }
    }
}
